{% load currency_filters %}
{% load reviews_tags %}
{% load thumbnail %}
{% load i18n %}

<article class="product_pod">
    {% block product_image %}
    <div class="image_container">
        {% with image=product.primary_image %}
            {% thumbnail image.original "150x150" upscale=False as thumb %}
                <a href="{{ product.get_absolute_url }}">
                    <img src="{{ thumb.url }}" alt="{{ product.get_title }}">
                    {% if not product.is_available_to_buy %}<i class="unavailable"></i>{% endif %}
                </a>
            {% endthumbnail %}
        {% endwith %}
    </div>
    {% endblock %}

    {% block product_title %}
    <h3>
        <!--<span>
            {% if product.is_available_to_buy %}
                {{ product.stockrecord.partner.name|truncatechars:19 }}
            {% else %}
                {% trans "No disponible" %}
            {% endif %}
        </span>-->
        <a href="{{ product.get_absolute_url }}">{{ product.get_title|truncatechars:30 }}</a>
    </h3>
    {% endblock %}

    {% block product_price %}
    <div class="product_price">
        <h4 class="price_color">{% include "catalogue/partials/stock_record.html" %}</h4>

        {% if user.is_authenticated %}
        <form action="{% url basket:add %}" method="post">
            {% csrf_token %}
            {{ basket_form.as_p }}
            {% if product.is_available_to_buy %}
                {% if product.is_group %}
                    <a class="btn btn-block" href="{% url catalogue:detail product.slug product.id %}">{% trans "Seleccionar Talle" %}</a>
                {% else %}
                    <button type="submit" class="btn btn-block btn-primary btn-full">{% trans "Add to basket" %}</button>
                {% endif %}
            {% else %}
                <span class="btn btn-info btn-block disabled">{% trans "No disponible" %}</span>
            {% endif %}
        </form>
        {% endif %}
    {% endblock %}

</article>
